home *** CD-ROM | disk | FTP | other *** search
Text File | 1994-12-05 | 2.1 KB | 81 lines | [TEXT/MPS ] |
- /*
- File: mtb8.c
- Contains: Video Media Functions
- Written by: DTS and QT Engineering
- Copyright: © 1992-1994 by Apple Computer, Inc., all rights reserved.
- Change History (most recent first):
- <1> 12/4/94 khs changed the format of the file to the new look and feel
- To Do:
- */
-
-
- // INCLUDE FILES
- #include "mtb.h"
-
-
- // FUNCTIONS
- void AddVideoSamplesToMedia(Media theMedia,
- const Rect* trackFrame)
- {
- long maxCompressedSize;
- GWorldPtr theGWorld = nil;
- long curSample;
- Handle compressedData = nil;
- Ptr compressedDataPtr;
- ImageDescriptionHandle imageDesc = nil;
- CGrafPtr oldPort;
- GDHandle oldGDeviceH;
- OSErr err = noErr;
-
- err = NewGWorld(&theGWorld, 16, // pixel depth
- trackFrame, nil, nil, (GWorldFlags)0);
- CheckError(err, "\pNewGWorld");
-
- LockPixels(theGWorld->portPixMap);
-
- err = GetMaxCompressionSize(theGWorld->portPixMap, trackFrame, 0,// let ICM choose depth
- codecNormalQuality, 'rle ', (CompressorComponent)anyCodec, &maxCompressedSize);
- CheckError(err, "\pGetMaxCompressionSize");
-
- compressedData = NewHandle(maxCompressedSize);
- CheckError(MemError(), "\pNewHandle");
-
- MoveHHi(compressedData);
- HLock(compressedData);
- compressedDataPtr = StripAddress(*compressedData);
-
- imageDesc = (ImageDescriptionHandle)NewHandle(4);
- CheckError(MemError(), "\pNewHandle");
-
- GetGWorld(&oldPort, &oldGDeviceH);
- SetGWorld(theGWorld, nil);
-
- //••••••• changed to <= 30
- for (curSample = 1; curSample <= 30; curSample++)
- {
- EraseRect(trackFrame);
- DrawFrame(trackFrame, curSample);
-
- err = CompressImage(theGWorld->portPixMap, trackFrame, codecNormalQuality, 'rle ', imageDesc, compressedDataPtr);
- CheckError(err, "\pCompressImage");
-
- err = AddMediaSample(theMedia, compressedData, 0,// no offset in data
- (**imageDesc).dataSize, 60,// frame duration = 1/10 sec
- (SampleDescriptionHandle)imageDesc, 1,// one sample
- 0, // self-contained samples
- nil);
- CheckError(err, "\pAddMediaSample");
- }
-
- SetGWorld(oldPort, oldGDeviceH);
-
- if (imageDesc)
- DisposeHandle((Handle)imageDesc);
- if (compressedData)
- DisposeHandle(compressedData);
- if (theGWorld)
- DisposeGWorld(theGWorld);
- }
-
-
-